﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RobotControl
{
    public class RobotData
    {
        public List<DateTime> 时间 = new List<DateTime>();
        public List<double> 经度 = new List<double>();
        public List<double> 纬度 = new List<double>();
        public List<double> 深度 = new List<double>();
        public List<double> 高度 = new List<double>();
        public List<double> 航向 = new List<double>();
        public List<double> 传感器1 = new List<double>();
        public List<double> 传感器2 = new List<double>();
        public List<double> 传感器3 = new List<double>();
        public List<double> 传感器4 = new List<double>();
        
        Form_Main f;
        public RobotData(Form_Main _f)
        {
            AddData();
            f = _f;
        }
        public void ClearAll()
        {
            时间.Clear();
            经度.Clear();
            纬度.Clear();
            深度.Clear();
            高度.Clear();
            航向.Clear();
            传感器1.Clear();
            传感器2.Clear();
            传感器3.Clear();
            传感器4.Clear();
            AddData();
        }
        public void AddData()
        {
            时间.Add(DateTime.Now);
            经度.Add(0.0);
            纬度.Add(0.0);
            深度.Add(0.0);
            高度.Add(0.0);
            航向.Add(0.0);
            传感器1.Add(0.0);
            传感器2.Add(0.0);
            传感器3.Add(0.0);
            传感器4.Add(0.0);
        }
        public void SetCurData(ParamsListAddr addr, object o)
        {
            bool bF = false;
            switch (addr)
            {
                case ParamsListAddr.深度:
                    深度[深度.Count - 1] = Convert.ToDouble(o);
                    bF = true;
                    break;
                case ParamsListAddr.高度:
                    高度[高度.Count - 1] = Convert.ToDouble(o);
                    break;
                case ParamsListAddr.纬度:
                    纬度[纬度.Count - 1] = Convert.ToDouble(o);
                    break;
                case ParamsListAddr.经度:
                    bF = true;
                    经度[经度.Count - 1] = Convert.ToDouble(o);
                    break;
                case ParamsListAddr.航向:
                    航向[航向.Count - 1] = Convert.ToDouble(o);
                    break;
                case ParamsListAddr.传感器1:
                    传感器1[传感器1.Count - 1] = Convert.ToDouble(o);
                    break;
                case ParamsListAddr.传感器2:
                    传感器2[传感器2.Count - 1] = Convert.ToDouble(o);
                    break;
                case ParamsListAddr.传感器3:
                    传感器3[传感器3.Count - 1] = Convert.ToDouble(o);
                    break;
                case ParamsListAddr.传感器4:
                    传感器4[传感器4.Count - 1] = Convert.ToDouble(o);
                    break;
                case ParamsListAddr.时间:
                    时间[时间.Count - 1] = Convert.ToDateTime(o);
                    break;
            }
            if(bF)
                f.ExternGraph3D(纬度.ToArray(), 经度.ToArray(), 深度.ToArray());
        }
        public void LoadDatas(List<double> _深度,
        List<double> _高度 ,
        List<double> _Latitude,
        List<double> _Longitude)
        {
            深度 = new List<double>(_深度);
            高度 = new List<double>(_高度);
            纬度=new List<double>(_Latitude);
            经度 = new List<double>(_Longitude);
            f.ExternGraph3D(纬度.ToArray(), 经度.ToArray(), 深度.ToArray());
        }
        public void LoadData(string str)
        {
            char[] charSeparators = new char[] { ' ' };
            string[] Params = str.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
            if (Params.Length == 11)
            {
                时间[时间.Count - 1] = Convert.ToDateTime(Params[0] + " " + Params[1]);
                经度[经度.Count - 1] = Convert.ToDouble(Params[2]);
                纬度[纬度.Count - 1] = Convert.ToDouble(Params[3]);
                深度[深度.Count - 1] = Convert.ToDouble(Params[4]);
                高度[高度.Count - 1] = Convert.ToDouble(Params[5]);
                航向[航向.Count - 1] = Convert.ToDouble(Params[6]);
                传感器1[传感器1.Count - 1] = Convert.ToDouble(Params[7]);
                传感器2[传感器2.Count - 1] = Convert.ToDouble(Params[8]);
                传感器3[传感器3.Count - 1] = Convert.ToDouble(Params[9]);
                传感器4[传感器4.Count - 1] = Convert.ToDouble(Params[10]);
                AddData();
            }
        }
    }
}
